![]() |
Kinetis SDK API Reference Manual
1.0.0-beta
Freescale Semiconductor, Inc.
|
The section describes the programming interface of the GPIO Peripheral driver. More...
Data Structures | |
| struct | gpio_input_pin_t |
| The GPIO input pin configuration structure. More... | |
| struct | gpio_output_pin_t |
| The GPIO output pin configuration structure. More... | |
| struct | gpio_input_pin_user_config_t |
| The GPIO input pin structure. More... | |
| struct | gpio_output_pin_user_config_t |
| The GPIO output pin structure. More... | |
Typedefs | |
| typedef void(* | gpio_isr_callback_t )(void) |
| The GPIO ISR callback function. | |
GPIO Pin Macros | |
| #define | GPIO_PINS_OUT_OF_RANGE (0xFFFFFFFFU) |
| Indicates the end of a pin configuration structure. More... | |
| #define | GPIO_PORT_SHIFT (0x8U) |
| Bits shifted for the GPIO port number. More... | |
| #define | GPIO_MAKE_PIN(r, p) (((r)<< GPIO_PORT_SHIFT) | (p)) |
| Combines the port number and the pin number into a single scalar value. More... | |
| #define | GPIO_EXTRACT_PORT(v) (((v) >> GPIO_PORT_SHIFT) & 0xFFU) |
| Extracts the port number from a combined port and pin value. More... | |
| #define | GPIO_EXTRACT_PIN(v) ((v) & 0xFFU) |
| Extracts the pin number from a combined port and pin value. More... | |
Initialization | |
| void | gpio_init (const gpio_input_pin_user_config_t *inputPins, const gpio_output_pin_user_config_t *outputPins) |
| Initialize all GPIO pins used by board. More... | |
| void | gpio_input_pin_init (const gpio_input_pin_user_config_t *inputPin) |
| Initializes one GPIO input pin used by board. More... | |
| void | gpio_output_pin_init (const gpio_output_pin_user_config_t *outputPin) |
| Initializes one GPIO output pin used by board. More... | |
Pin Direction | |
| uint32_t | gpio_get_pin_direction (uint32_t pinName) |
| Gets the current direction of the individual GPIO pin. More... | |
| void | gpio_set_pin_direction (uint32_t pinName, gpio_pin_direction_t direction) |
| Sets the current direction of the individual GPIO pin. More... | |
Output Operations | |
| void | gpio_write_pin_output (uint32_t pinName, uint32_t output) |
| Sets the output level of the individual GPIO pin to the logic 1 or 0. More... | |
| void | gpio_set_pin_output (uint32_t pinName) |
| Sets the output level of the individual GPIO pin to the logic 1. More... | |
| void | gpio_clear_pin_output (uint32_t pinName) |
| Sets the output level of the individual GPIO pin to the logic 0. More... | |
| void | gpio_toggle_pin_output (uint32_t pinName) |
| Reverses current output logic of the individual GPIO pin. More... | |
Input Operations | |
| uint32_t | gpio_read_pin_input (uint32_t pinName) |
| Reads the current input value of the individual GPIO pin. More... | |
Interrupt | |
| void | gpio_clear_pin_interrupt_flag (uint32_t pinName) |
| Clears the individual GPIO pin interrupt status flag. More... | |
| void | gpio_register_isr_callback_function (uint32_t pinName, gpio_isr_callback_t function) |
| Registers the GPIO ISR callback function. More... | |
| struct gpio_input_pin_t |
Although every pin is configurable, valid configurations depend on a specific SoC. Users should check the related reference manual to ensure that the specific feature is valid in an individual pin. A configuration of unavailable features is harmless, but takes no effect.
Data Fields | |
| bool | isPullEnable |
| Enable or disable pull. More... | |
| port_pull_t | pullSelect |
| Select internal pull(up/down) resistor. More... | |
| bool | isPassiveFilterEnabled |
| Enable or disable passive filter. More... | |
| port_interrupt_config_t | interrupt |
| Select interrupt/DMA request. More... | |
| bool gpio_input_pin_t::isPullEnable |
| port_pull_t gpio_input_pin_t::pullSelect |
| bool gpio_input_pin_t::isPassiveFilterEnabled |
| port_interrupt_config_t gpio_input_pin_t::interrupt |
| struct gpio_output_pin_t |
Although every pin is configurable, valid configurations depend on a specific SoC. Users should check the related reference manual to ensure that the specific feature is valid in an individual pin. The configuration of unavailable features is harmless, but takes no effect.
Data Fields | |
| uint32_t | outputLogic |
| Set default output logic. More... | |
| port_slew_rate_t | slewRate |
| port_drive_strength_t | driveStrength |
| Select fast/slow slew rate. More... | |
| uint32_t gpio_output_pin_t::outputLogic |
| port_drive_strength_t gpio_output_pin_t::driveStrength |
Select low/high drive strength.
| struct gpio_input_pin_user_config_t |
Although the pinName is defined as a uint32_t type, values assigned to the pinName should be the enumeration names defined in the enum _gpio_pins.
Data Fields | |
| uint32_t | pinName |
| Virtual pin name from enum defined by the user. More... | |
| gpio_input_pin_t | config |
| Input pin configuration structure. More... | |
| uint32_t gpio_input_pin_user_config_t::pinName |
| gpio_input_pin_t gpio_input_pin_user_config_t::config |
| struct gpio_output_pin_user_config_t |
Although the pinName is defined as a uint32_t type, values assigned to the pinName should be the enumeration names defined in the enum _gpio_pins.
Data Fields | |
| uint32_t | pinName |
| Virtual pin name from enum defined by the user. More... | |
| gpio_output_pin_t | config |
| Input pin configuration structure. More... | |
| uint32_t gpio_output_pin_user_config_t::pinName |
| gpio_output_pin_t gpio_output_pin_user_config_t::config |
| #define GPIO_PINS_OUT_OF_RANGE (0xFFFFFFFFU) |
| #define GPIO_PORT_SHIFT (0x8U) |
| #define GPIO_MAKE_PIN | ( | r, | |
| p | |||
| ) | (((r)<< GPIO_PORT_SHIFT) | (p)) |
| #define GPIO_EXTRACT_PORT | ( | v | ) | (((v) >> GPIO_PORT_SHIFT) & 0xFFU) |
| #define GPIO_EXTRACT_PIN | ( | v | ) | ((v) & 0xFFU) |
| void gpio_init | ( | const gpio_input_pin_user_config_t * | inputPins, |
| const gpio_output_pin_user_config_t * | outputPins | ||
| ) |
To initialize the GPIO driver, define two arrays similar to the gpio_input_pin_user_config_t inputPin[] and the gpio_output_pin_user_config_t outputPin[] in the user file. Then, call the gpio_init() function and pass in the two arrays. If the input or output pins are not needed, pass in a NULL.
This is an example to define an input pin array:
| inputPins | input GPIO pins pointer. |
| outputPins | output GPIO pins pointer. |
| void gpio_input_pin_init | ( | const gpio_input_pin_user_config_t * | inputPin | ) |
| inputPins | input GPIO pins pointer. |
| void gpio_output_pin_init | ( | const gpio_output_pin_user_config_t * | outputPin | ) |
| outputPins | output GPIO pins pointer. |
| uint32_t gpio_get_pin_direction | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| void gpio_set_pin_direction | ( | uint32_t | pinName, |
| gpio_pin_direction_t | direction | ||
| ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| direction | GPIO directions.
|
| void gpio_write_pin_output | ( | uint32_t | pinName, |
| uint32_t | output | ||
| ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| output | pin output logic level.
|
| void gpio_set_pin_output | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| void gpio_clear_pin_output | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| void gpio_toggle_pin_output | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| uint32_t gpio_read_pin_input | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| void gpio_clear_pin_interrupt_flag | ( | uint32_t | pinName | ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| void gpio_register_isr_callback_function | ( | uint32_t | pinName, |
| gpio_isr_callback_t | function | ||
| ) |
| pinName | GPIO pin name defined by the user in the GPIO pin enumeration list. |
| function | Pointer to the GPIO ISR callback function. |